package itheima.lianxi2;


import java.util.ArrayList;

public class lianxi {
    public static void main(String[] args) {
        ArrayList<Teacher> list = new ArrayList<>();
        Teacher tch1 = new Teacher("果果老师","javase");
        Teacher tch2 = new Teacher("张三丰老师","javaee");
        Teacher tch3 = new Teacher("张无忌老师","php");
        Teacher tch4 = new Teacher("张有忌老师","python");

        list.add(tch1);
        list.add(tch2);
        list.add(tch3);
        list.add(tch4);

        String str = "";
        for (int i = 0; i < list.size(); i++) {
            Teacher te = list.get(i);
            if (i == list.size() - 1){
                str = str + te.getProject();
            }else {
                str = str + te.getProject() + ",";
            }

            System.out.println("姓名：" + te.getName() + "，专业：" + te.getProject());
        }
        System.out.println("专业：" + str);
    }
}
